package util.AST.Expressao;

import checker.SemanticException;
import checker.Visitor;
import util.AST.Terminal.OpAri;

public class ExpressaoAri extends Expressao {
	
	private String tipo;
	private ExpressaoAriPrimaria expPriEsq;
	private OpAri operador;
	private ExpressaoAriPrimaria expPriDir;
	
	public ExpressaoAri(ExpressaoAriPrimaria expEsq, OpAri op, ExpressaoAriPrimaria expDir){
		this.expPriEsq = expEsq;
		this.operador = op;
		this.expPriDir = expDir;
	}
	
	public ExpressaoAri(){
		
	}
	
	public ExpressaoAriPrimaria getExpressaoPriEsq(){
		return this.expPriEsq;
	}
	
	public OpAri getOperador(){
		return this.operador;
	}
	
	public ExpressaoAriPrimaria getExpressaoPriDir(){
		return this.expPriDir;
	}

	public String toString(int level) {
		int nextLevel = level+5;
		StringBuffer str = new StringBuffer();
		str.append("ExpAri\n");
		if ( this.expPriEsq != null ) {
			str.append(super.getSpaces(nextLevel) + "|-" + this.expPriEsq.toString(nextLevel));
		}
		if ( this.operador != null ) {
			str.append(super.getSpaces(nextLevel) + "|-" + this.operador.toString(nextLevel));
		}
		if ( this.expPriDir != null ) {
			str.append(super.getSpaces(nextLevel) + "|-" + this.expPriDir.toString(nextLevel));
		}
		return str.toString();
	}

	@Override
	public Object visit(Visitor v, Object o) throws SemanticException {
		return v.visitExpressaoAri(this, o);
	}

	public String getTipo() {
		return tipo;
	}

	public void setTipo(String tipo) {
		this.tipo = tipo;
	}
	
}
